import { Controller } from 'egg';
class FeedbackController extends Controller {
    /**
     * 查询反馈列表
     */
    public async searchFeedbackList() {
        const { ctx, ctx: { request } } = this;
        try {
            ctx.validate({
                page: 'string',
                size: 'string',
            }, request.body)
        } catch (e) {
            ctx.body = ctx.helper.responseErrorParam(e.errors[0].message);
            return;
        }
        const result = await ctx.service.feedbackService.searchFeedbackList(request.body);
        ctx.body = ctx.helper.responseSuccess('查询成功', result);
    }

    /**
     * 新增问题反馈
     */
    public async createFeedback() {
        const { ctx, ctx: { request } } = this;
        try {
            ctx.validate({
                feedback_title: 'string',
                feedback_content: 'string',
                feedback_phone: 'string',
            }, request.body)
        } catch (e) {
            ctx.body = ctx.helper.responseErrorParam(e.errors[0].message);
            return;
        }
        await ctx.service.feedbackService.createFeedback(request.body);
        ctx.body = ctx.helper.responseSuccess('反馈成功');
    }
}
export default FeedbackController;